﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Philippine_National_Red_Cross
{
    public partial class Main : Form
    {
        string usePassword, useUsername;
        public Main(string user,string pass)
        {
            this.useUsername = user;
            this.usePassword = pass;

            InitializeComponent();
            MenuRegister.Click += new EventHandler(MenuRegister_Click);
            MenuSearch.Click += new EventHandler(MenuSearch_Click);
            MenuLogout.Click += new EventHandler(MenuLogout_Click);
            MenuNewUser.Click += new EventHandler(MenuNewUser_Click);
            MenuChangePass.Click += new EventHandler(MenuChangePass_Click);
            MenuExit.Click += new EventHandler(MenuExit_Click);
            timer1.Tick += new EventHandler(timer1_Tick);
            timer1.Start();
        }

        void MenuExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

       
        void MenuChangePass_Click(object sender, EventArgs e)
        {
            frmChangePassword frm = new frmChangePassword(useUsername, usePassword);
            frm.ShowDialog();
            
        }

        void MenuNewUser_Click(object sender, EventArgs e)
        {
            frmSignup frm1 = new frmSignup();
            frm1.ShowDialog();
        }

        void MenuLogout_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to logout?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                this.Hide();
                Login frm = new Login();
                frm.ShowDialog();
                this.Close();
            }
            else if (result == DialogResult.No) { return; }
            
        }

        void timer1_Tick(object sender, EventArgs e)
        {
            MenuTime.Text = DateTime.Now.ToString("hh:mm:ss tt");
        }

      
        void MenuSearch_Click(object sender, EventArgs e)
        {
            Search frm3 = new Search();
            frm3.ShowDialog(this);
        }

        void MenuRegister_Click(object sender, EventArgs e)
        {
            frmRegister frm2 = new frmRegister();
            frm2.ShowDialog();
        }


        public void LevelofAccess(string position)
        {
            switch (position)
            {
                case "Admin":
                    MenuChangePass.Enabled = true;
                    MenuSearch.Enabled = true;
                    MenuNewUser.Enabled = true;
                    break;
            }
        }

    }
}
